package top.boking.dao;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import top.boking.domain.Cla;

import java.util.List;

public interface ClaDao {
    @Select("select *from classes where claid =#{integer}")
    @Results(id = "cla"/*这个id用于标记本标签，方便复用，如果无需复用则可以不加*/, value = {
            @Result(id = true, property = "id", column = "claid"),
            @Result(property = "name", column = "cname")
    }
    )
    List<Cla> findByid(Integer integer);

    @Select("select *from classes")
    //@ResultMap("cla")//调用id为cla的results标签
    @Results(id = "clas", value = {
            @Result(id = true, property = "id", column = "claid"),
            @Result(property = "name", column = "cname"),
            @Result(property = "students",column = "claid",many=@Many(select = "top.boking.dao.StudentDao.findByid",fetchType = FetchType.EAGER))

    }
    )

    List<Cla> findOtM();

         @Select("select *from classes where claid = #{id} and cname = #{name}")
    List<Cla> findByCla(Cla cla);





}
